<%-- 
    Document   : index
    Created on : 24-Jan-2012, 19:54:12
    Author     : theInterloper
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Collection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "Web.*"%>
<%@ page import = "Entity.*"%>
<%
shopControl.loadAllItemsToSession(request, response);
shopControl.loadAllArtistsToSession(request, response);

                        
                        Boolean checkArtistIsLoggedIn = (Boolean)session.getAttribute("artistisloggedin");
                        Boolean checkCustomerIsLoggedIn = (Boolean)session.getAttribute("customerisloggedin");
                        System.out.println("Customer session is: " + checkCustomerIsLoggedIn);
                        System.out.println("Artist session is: " + checkArtistIsLoggedIn);
                       
                        if(checkArtistIsLoggedIn == null){
                            checkArtistIsLoggedIn = false;
                            session.setAttribute("artistisloggedin", new Boolean(checkArtistIsLoggedIn));
                            System.out.println("Login checked artist is null, set to " + checkArtistIsLoggedIn);
                                         
                            
                        }
                        if(checkCustomerIsLoggedIn == null){
                            checkCustomerIsLoggedIn = false;
                            session.setAttribute("customerisloggedin", new Boolean(checkCustomerIsLoggedIn));
                            System.out.println("Login checked customer is null, set to " + checkCustomerIsLoggedIn);
                                         
                            
                        }
%>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

	<title></title>
	<meta name="description" content="">
	<meta name="author" content="">

	<meta name="viewport" content="width=device-width,initial-scale=1">

	<link rel="stylesheet" href="${pageContext.request.contextPath}/parts/css/style.css">

	<script src="${pageContext.request.contextPath}/parts/js/libs/modernizr-2.0.6.min.js"></script>
</head>
<body>
	<div id="header-container">
		<header class="wrapper">
			<h1 id="title">Crafty Webshop </h1>
			<nav>
				<ul>
					<li><a href="${pageContext.request.contextPath}/index.jsp">Home</a></li>
					<li><a href="${pageContext.request.contextPath}/allitems.jsp">Pieces</a></li>
					<li><a href="${pageContext.request.contextPath}/allartists.jsp">Artists</a></li>
				</ul>
			</nav>
		</header>
	</div>
	<div id="main" class="wrapper">
		<aside>
                    <%@include file="WEB-INF/jspf/sidebar.jspf"%>
		</aside>
		<article>
                    <%
                    Artist artist = new Artist();
                    artist = (Artist)session.getAttribute("selectedartist");
                    out.print("<header><h2>" + artist.getFIRSTNAME() + " " + artist.getSECONDNAME() + "</h2>"+
                            "<h2>About:</h2>" +
                            "<h3>" + artist.getDESCRIPTION()+ "</h3>"+ 
                            "</header>");
                    out.print("<h2>Items:</h3>");
                    Collection itemCollection = new ArrayList<Item>();
                    itemCollection = (Collection) session.getAttribute("itemcollection");
                            Iterator it = itemCollection.iterator();
                            while (it.hasNext()) {
                                Item item = new Item();
                                item = (Item) it.next();
                                System.out.println("artist item trigger test: "+item.getARTIST_ARTISTID() + artist.getID() );
                                if(item.getARTIST_ARTISTID()== artist.getID()){
                                    out.print("<p>" + item.getNAME() + "</p>");
                                }
                            }
                    
                    %>
			
		</article>
	</div>
	<div id="footer-container">
		<footer class="wrapper">
			<h3>A nice footer</h3>
		</footer>
	</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="${pageContext.request.contextPath}/parts/js/libs/jquery-1.7.1.min.js"><\/script>')</script>

<!-- scripts concatenated and minified via ant build script-->
<script src="${pageContext.request.contextPath}/parts/js/plugins.js"></script>
<script src="${pageContext.request.contextPath}/parts/js/script.js"></script>
<!-- end scripts-->

</body>
</html>
